-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add WidgetSet endpoint #968
Conversation
c89a6cc
to
8dcddfa
Compare
@lpichler we also need an endpoint for copying I think |
It could be done by with create action but I can add it to simplify copy action. |
@lpichler as there's a separate method on the model for copying, I'd rather expose it than simulate it with a create... |
0103ab1
to
adea740
Compare
I'm not sure I like all of this in the API...feels like a lot of the setup should be in the model as class methods. @agrare @abellotti Thoughts? Is this a pattern we do elsewhere? |
ALLOWED_FIELDS = REQUIRED_FIELDS_TO_COPY + %w[group description guid read_only set_data].freeze | ||
SET_DATA_COLS = %i[col1 col2 col3].freeze | ||
|
||
def init_set_data(set_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything that's not exposed to a route should be moved into a private method.
|
||
def validate_description(group_id, description) | ||
widget_set_exists_in_group = MiqWidgetSet.exists?(:owner_id => group_id, :description => description) | ||
raise ArgumentError, "Description(Tab Title) must be unique for this group" if widget_set_exists_in_group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this stuff should be model validations...not in the API.
def create_resource(type, id = nil, data = nil) | ||
raise_if_unsupported_fields_passed(data) | ||
|
||
raise ArgumentError, "Name cannot contain \"|\"" if data['name'].index('|') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also should be a model validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, API does not raise any ArgumentErrors today, those come from the model.
Yes, this is exactly what I wanted to discuss - I am not against, I wanted to see opinions from others. cc @kbrock |
new_set_data[:reset_upon_login] = !!set_data['reset_upon_login'] | ||
new_set_data[:locked] = !!set_data['locked'] | ||
new_set_data | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused with this, is the API defining a structure beyond the basic MiqWidgetSet ? It almost feels we need a new subclass of MiqWidgetSet in the model for what we're building/managing here and move most of this logic in there.
adea740
to
39423a2
Compare
39423a2
to
1195455
Compare
1195455
to
f1b0339
Compare
From Pull Request: ManageIQ/manageiq-api#968
From Pull Request: ManageIQ/manageiq-api#968
@miq-bot cross-repo-tests ManageIQ/manageiq#20890 |
From Pull Request: ManageIQ/manageiq-api#968
f1b0339
to
4dea6a4
Compare
Checked commit lpichler@4dea6a4 with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint app/controllers/api/widget_sets_controller.rb
|
module Api | ||
class WidgetSetsController < BaseController | ||
REQUIRED_FIELDS_TO_COPY = %w[name].freeze | ||
ALLOWED_FIELDS = REQUIRED_FIELDS_TO_COPY + %w[group description guid read_only set_data].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with 'read_only' here, does this mean the API can create read_only widget sets and cannot delete them ? I usually think of read_only as set to true for some system seeded resources.
needs a bulk query test. can be added in spec/requests/collections_spec.rb |
This pull request is not mergeable. Please rebase and repush. |
From Pull Request: ManageIQ/manageiq-api#968
From Pull Request: ManageIQ/manageiq-api#968
@jrafanie This is needed for Overview/Reports/Dashboards -> Copy Selected Dashboard Missing endpoint for manipulating with dashboards form. Right now we are using miqajaxmethod as we don't have api. |
Fixes #953
This adds WidgetSet endpoint with CRUD.
LIST
CREATE:
EDIT:
COPY
DELETE
Links
Requires: